# -*- coding: utf-8 -*-

################################################################################
## Form generated from reading UI file '信号与槽.ui'
##
## Created by: Qt User Interface Compiler version 5.15.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################

from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *


class Ui_signal_slot(object):
    def setupUi(self, signal_slot):
        if not signal_slot.objectName():
            signal_slot.setObjectName(u"signal_slot")
        signal_slot.resize(800, 600)
        self.centralwidget = QWidget(signal_slot)
        self.centralwidget.setObjectName(u"centralwidget")
        self.close_button = QPushButton(self.centralwidget)
        self.close_button.setObjectName(u"close_button")
        self.close_button.setGeometry(QRect(380, 200, 93, 28))
        signal_slot.setCentralWidget(self.centralwidget)
        self.menubar = QMenuBar(signal_slot)
        self.menubar.setObjectName(u"menubar")
        self.menubar.setGeometry(QRect(0, 0, 800, 26))
        signal_slot.setMenuBar(self.menubar)
        self.statusbar = QStatusBar(signal_slot)
        self.statusbar.setObjectName(u"statusbar")
        signal_slot.setStatusBar(self.statusbar)

        self.retranslateUi(signal_slot)
        self.close_button.clicked.connect(signal_slot.close)    # 这里就是信号与槽之间的连接
        # 关闭窗口（close_button）在点击情况下（clicked）发出的信号被主窗口（signal_slot）的槽函数（close）捕获
        # 并触发了关闭主窗口的行为

        self.close_button.clicked.connect(self.showMessage)  # 自定义一个槽函数
        # 达到的效果是 点击关闭按钮会出现一个“欢迎进入PyQt5编程世界”提示框

        QMetaObject.connectSlotsByName(signal_slot)

    # 自定义一个槽函数（弹出对话框）
    def showMessage(self):
        from PySide2.QtWidgets import QMessageBox
        QMessageBox.information(MainWindow, "提示框", "欢迎进入PyQt5编程世界",
                                QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)

    # setupUi
    def retranslateUi(self, signal_slot):
        signal_slot.setWindowTitle(QCoreApplication.translate("signal_slot", u"\u4fe1\u53f7\u4e0e\u69fd", None))
        self.close_button.setText(QCoreApplication.translate("signal_slot", u"\u5173\u95ed", None))
    # retranslateUi




from PySide2 import QtWidgets
import sys
if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_signal_slot()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())

